//
//  GYMySaleProductViewModel.m
//  GYDemo
//
//  Created by Mrzhang on 2018/4/8.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYMySaleProductViewModel.h"
#import "Head.h"
@implementation GYMySaleProductViewModel
-(instancetype)init
{
    if (self = [super init]) {
        //添加接口特殊处理
        [[InterfaceManager shareInterface].specialInterfaces addObject:@"mySaleProduct"];
        
    }
    return self;
}
#pragma mark - method

-(void)requestDatas:(NSMutableDictionary *)para
{

    @WeakSelf;
    NSString *interface = @"mySaleProduct";
    NSString *page = para[@"page"];
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSDictionary *data = infoModel.data;
        if ([data isKindOfClass:[NSDictionary class]]) {
            NSArray *datalist = data[@"datalist"];
            
            if ([datalist count]<10) {
                selfp.canAddMore=NO;
            }else
            {
                selfp.canAddMore=YES;
            }
            if ([datalist isKindOfClass:[NSArray class]]) {
                NSMutableArray *arr;
                if ([page isEqualToString:@"1"]) {
                    arr = [NSMutableArray new];
                }else{
                    arr = self.datas;
                }
                for (NSDictionary *dic in datalist) {
                    GYMineLikeProductInfoModel *model = [GYMineLikeProductInfoModel yy_modelWithJSON:dic];
                    [arr addObject:model];
                }
                [selfp setDatas:arr];
                [selfp setTotalCount:[data objectForKey:@"total"]];
            }
        }else
        {
            self.canAddMore=NO;
            if ([page isEqualToString:@"1"])
            {
                NSMutableArray* arr;
                [selfp setDatas:arr];
            }
        }
    }];
}
@end
